Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] 이름 및 패키지 정리, Type-Safe Navigation 적용 #168

Merged
merged 48 commits into from
Feb 11, 2025

Conversation

miller198
Copy link
Collaborator

@miller198 miller198 commented Jan 21, 2025

#️⃣연관된 이슈

resolve #167

📝작업 내용 및 코드

아직 미완성입니다. 에러 해결중
image

변경된 내비게이션에 대한 내용 -> 여기

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

드디어 기어나온 PR
같이 에러 해결 해주세요

class GetUserIdFromDataStoreUseCase @Inject constructor(
    private val localRepository: LocalRepository
) {
    suspend operator fun invoke() : String? {
        return try {
            val userId = localRepository.readUserIdDataStore().first()
            if (userId.isNullOrBlank()) null else userId
        } catch (e: Exception) {
            Log.e("GetUserIdUseCase", "Error reading DataStore", e)
            null
        }
    }
}

앱이 시작되면 MainViewModel에서 이 유스케이스가 실행되면서
DataStore에 있는 UserId 를 가져옵니다.
만약 DataStore에 저장된 UserId가 없다면 (앱 최초실행) MainViewModel 의

viewModelScope.launch {
            val userId = getUserIdFromDataStoreUseCase()
            if(userId == null) {
                createUser()
            } else {
                fetchUser(userId)
            }
        }

에서 createUser()를 실행해서 파베에 유저를 추가하고
저장된 UserIde가 있다면 fetchUser()를 해서 파베에서 유저정보를 받아와서
LocalDataSource의 _currentUser 변수에 저장합니다.

그런데 지금 fetchUser() 분기에서 _currentUser에 저장하는 게 안되고 있어서
위의 사진과 같은 에러 로그가 나와요

최초실행해서 createUser()할때는 또 잘되서 앱이 잘 실행되요ㅡㅜ 왜그럴까욧

250123 추가

앱 데이터 지우고 들어갔을때 화면 이동은 잘 됩니다
검색 -> 등록 화면 넘어가는거만 빼구요

@Composable
internal fun MapBottomBar(
    modifier: Modifier = Modifier,
    userId: String,
    lastLocation: Location?,
    onFavoriteClick: () -> Unit,
    onCenterClick: () -> Unit,
    onProfileClick: () -> Unit
)

BottomNavigation 코드를 위와 같이 바꾸었는데
여기서 원래 userId가 없었거든요 이게 생겨서 나타나는 문제같습니다 더 알아볼게요

MapBottomBar(
            modifier = Modifier.padding(bottom = 16.dp),
            userId = mapViewModel.getUserId(),
            lastLocation = lastLocation,
            onFavoriteClick = {
                onFavoriteClick(mapViewModel.getUserId())
            },
            onCenterClick = {
                onCenterClick()
                mapViewModel.saveCurLocationForced()
            },
            onProfileClick = {
                onProfileClick(mapViewModel.getUserId())
            }
        )

250124

위에 쓴 내용이 원인 맞네요
해당 부분 수정하고 잘 실행 됩니다.
이제 내비게이션 동작이 모두 완벽히 되도록 진행중입니다
현재 Search -> Create 로 넘어갈때 새로 노래 정보를 불러오는게 아니라 Song 인스턴스를 전달하는 방식으로 하고 있는데
이게 잘 안되네요

250125

내비게이션 모두 수정 완료 했습니다.
실행 해보시고 안되는 부분 있으면 알려주세요

@miller198 miller198 added refactor 리팩토링, 코드개선 chore 빌드 및 패키지 labels Jan 21, 2025
@miller198 miller198 added this to the 프로젝트 기반 설정 milestone Jan 21, 2025
@miller198 miller198 requested review from yuni-ju and meanjoo January 21, 2025 12:28
@miller198 miller198 self-assigned this Jan 21, 2025
@miller198 miller198 changed the title [refactor] 각종 이름 및 패키지 정리, Type-Safe Navigation 적용 [refactor] 이름 및 패키지 정리, Type-Safe Navigation 적용 Jan 21, 2025
@miller198
Copy link
Collaborator Author

miller198 commented Jan 30, 2025

픽상세화면에서 뒤로 가기 시 무조건 지도로 돌아가더라구요 고칠 예정입니다!

화면 별 기능이 더 직관적으로 드러나도록 변경
화면 별 기능이 더 직관적으로 드러나도록 변경
Copy link
Collaborator

@yuni-ju yuni-ju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존의 네비게이션보다 경로가 더 직관적이고, 파일도 분리해주셔서 좋네요!
type-safe한 인자 전달 넘 좋습니다. 대대적인 수정하시느라 정말 고생하셨습니다! 😄👍👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우선 저도 common/picklist와 picklist패키지에 동일한 파일이 들어가있는 것을 보았는데 민주님이 말씀해주신 대로 하나로 정리되면 삭제해도 될 것 같아요.
이때 개인적으로 common내부에 너무 많은 파일을 담기보다는 picklist패키지에 남겨두는 것이 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 기존 picklist 패키지는 모두 지웠습니다.
common에 많은 파일이 있는건 모듈 분리하면서 picklist를 core 모듈로 따로 뺄 예정이라 괜찮아질거에요(아마)
기대해주세요...!! ㅋㅋ

private val searchSongsUseCase: SearchSongsUseCase,
savedStateHandle: SavedStateHandle,
getLastLocationUseCase: GetLastLocationUseCase,
private val fetchSongsUseCase: FetchSongsUseCase,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchSongsUseCase는 현재 사용되지 않는 코드인 것 같습니다. 제거해도 될 것 같아요!

) {
val song = createPickViewModel.selectedSong ?: DEFAULT_SONG
// val song = createPickViewModel.selectedSong ?: DEFAULT_SONG
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는다면 지워지지 않은 주석이 있습니닷!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 파일 detail 패키지로 수정 필요합니다.

Comment on lines 48 to 54
PickDetailScreen(
pickId = pickId,
playerServiceViewModel = playerServiceViewModel,
onProfileClick = onProfileClick,
onBackClick = onBackClick,
onDeleted = onDeleted,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigatePickDetailMapNavigation에 존재해서 프로필 화면이나 내가 담은 픽 화면에서 PickDetail화면으로 이동 후 뒤로가기를 누르면 모두 지도 화면으로 이동합니다.

다른 화면들의 onBackClick은 popBackStackIfNotMap로 되어있는 것과 달리 mapNavGraph를 통해 onBackClick = navigator::navigateMap로 되어있어서 발생하는 문제인 것 같습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miller198 한시간 넘게 리뷰하느라 그동안 코멘트 추가하신걸 못봤네요..!!! 😅😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

픽을 등록하고 디테일로 넘어갔을때는 뒤로가기 시 지도로 나가야 하고
다른 경우에는 직전 화면으로 가야되는데
제가 무조건 지도로만 가게 해놨었네요
지금은 경우에 따라 적절히 동작하도록 수정하였습니다!

@miller198 miller198 changed the title [refactor] 이름 및 패키지 정리, Type-Safe Navigation 적용 [fix] 이름 및 패키지 정리, Type-Safe Navigation 적용 Jan 30, 2025
@miller198 miller198 changed the title [fix] 이름 및 패키지 정리, Type-Safe Navigation 적용 [refactor] 이름 및 패키지 정리, Type-Safe Navigation 적용 Jan 30, 2025
@miller198 miller198 requested review from yuni-ju and meanjoo January 30, 2025 18:39
@meanjoo
Copy link
Collaborator

meanjoo commented Feb 4, 2025

다시 하는 리뷰가 너무 늦었네요 죄송합니닷..┗( T﹏T )┛

앞서 제가 말씀드렸던 부분 반영해주신 거 확인했는데 좋습니다!
이전 리뷰 이후의 변경 사항들도 확인했습니당 고생하셨어요👍
윤겸님 PR 머지되면서 생긴 컨플릭트 해결하시고 머지하면 될 것 같아요 '~'

그리고 이 PR과는 무관해보여서 PR 승인을 했는데 저희 예전에 있던 이슈가 다시^^...

내비게이션 이동이 잘 되는지 확인해보다가 음악 재생을 했을 때 이렇게 가끔 이렇게 재생/일시정지 버튼이 안 되는 경우가 있더라구요?
재생을 하면 시각화도 잘 뜨고 음악도 잘 들리고 5초 전/후 가기도 잘 되는데 재생 버튼이 일시정지 버튼으로 안 바뀌어서 픽 상세정보 화면에서는 영원히 노래를 듣게 되는 문제가 .... 그리고 이렇게 되는 경우에는 seekbar도 동작을 안 하는 것 같네요
그런데 역시나 예전과 같이 이렇게 되는 상황의 조건을 모르겠어서 답답하네요 ㅋㅋㅋ,,,,,,ㅜ

아무튼 정말 고생하셨습니다!!

@miller198 miller198 merged commit 8894e3f into develop Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore 빌드 및 패키지 refactor 리팩토링, 코드개선
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[프로젝트 기반 설정] 내비게이션 개선
3 participants